#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include "EquationSolver.h"

using namespace std;

class func: public Function
{
    public:
        double L = 10.0;
        double r = 1.0;
        double V_standard = 12.4;

        double get_value(double x){
            
            double V = L*(0.5*M_PI*r*r - r*r*asin(x/r) - x*sqrtf(r*r-x*x));
            return V-V_standard;
        }
        /*double get_derivation(double x){
            double V_der = -2*L*sqrtf(r*r-x*x);
            return V_der;
        }*/
}f;

int main()
{
    double e = 0.0001;
    double d = 0.0001;
    double m = 50;

    Bisection bis_solver(e, d, m);
    Newton new_solver(e, m);
    Secant sec_solver(e, d, m);

    InitInput input1(f), input2(f), input3(f);
    input1.setBisectionInput(0, 1);
    double h1 = bis_solver.solve(input1);
    cout << "Bisection method: h1 = " << h1 << endl;

    input2.setNewtonInput(0.1);
    double h2 = new_solver.solve(input2);
    cout << "Newton's method: h2 = " << h2 << endl;

    input3.setSecantInput(0, 1);
    double h3 = sec_solver.solve(input3);
    cout << "Secant method: h3 = " << h3 << endl;

    return 0;
}